package mastermanagment.view;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;

public class ProjectInfoView extends JPanel
{
	private JButton btnSave;
	private JButton btnUpdate;
	private JButton btnBack;
	private JButton btnSearch;
	private JButton btnForward;
	private JButton btnClear;
	private JLabel lblprojectName;
	private JTextField tfprojectName;
	private JButton[] buttongrp=new JButton[8];
	private JTextField tfprojectId;
	private JLabel lblActive;
	private JButton btnMarkInactive;
	
	public ProjectInfoView() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		this.setBackground(new Color(239,239,239));
	    this.setPreferredSize(new Dimension(360, 450));
		
		/*
		 * SETTING LABELS
		 */
		 String[] labelsTitle = {"Name: ", "Phone: ", "Email: ", "Address: "};
		 JLabel[] labels=new JLabel[4];
		 
		 for(int i=0;i<labels.length;i++)
		 {
			 labels[i]=new JLabel(labelsTitle[i], JLabel.TRAILING);
			 add(labels[i]);
		 }
		
		tfprojectId = new JTextField();
		tfprojectId.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfprojectId, 10, SpringLayout.NORTH, this);
		tfprojectId.setEditable(false);
		add(tfprojectId);
		tfprojectId.setVisible(false);
		tfprojectId.setColumns(10);
		
		JLabel lblCatCode = new JLabel("Project Id :");
		lblCatCode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.SOUTH, lblCatCode, 0, SpringLayout.SOUTH, tfprojectId);
		springLayout.putConstraint(SpringLayout.EAST, lblCatCode, -6, SpringLayout.WEST, tfprojectId);
		add(lblCatCode);
		
		lblprojectName = new JLabel("Project Name");
		lblprojectName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblprojectName, 20, SpringLayout.SOUTH,tfprojectId);
		springLayout.putConstraint(SpringLayout.WEST, lblprojectName, 30, SpringLayout.WEST, this);
		add(lblprojectName);
		
		tfprojectName = new JTextField();
		springLayout.putConstraint(SpringLayout.EAST, tfprojectId, 0, SpringLayout.EAST, tfprojectName);
		tfprojectName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tfprojectName, 6, SpringLayout.SOUTH, lblprojectName);
		springLayout.putConstraint(SpringLayout.WEST, tfprojectName, 30, SpringLayout.WEST,this);
		add(tfprojectName);
		tfprojectName.setPreferredSize(new Dimension(300, 23));
		
		JPanel panel = new JPanel();
		springLayout.putConstraint(SpringLayout.NORTH, panel, 20, SpringLayout.SOUTH, tfprojectName);
		springLayout.putConstraint(SpringLayout.WEST, panel, 30, SpringLayout.WEST,this);
		add(panel);
		panel.setPreferredSize(new Dimension(300, 120));
		GridLayout g=new GridLayout(2,3,2,2);
		panel.setLayout(g);

		btnSave = new JButton("SAVE  ");
		btnSave.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSave);
		btnSave.setActionCommand("SAVE");
		buttongrp[0]=btnSave;
		
		btnClear = new JButton("CLEAR ");
		btnClear.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnClear);
		btnClear.setActionCommand("CLEAR");
		buttongrp[6]=btnClear;
		
		btnUpdate = new JButton("UPDATE");
		btnUpdate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnUpdate);
		btnUpdate.setActionCommand("UPDATE");
		buttongrp[2]=btnUpdate;
		
		btnBack = new JButton("  <<  ");
		btnBack.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnBack);
		btnBack.setActionCommand("<< ");
		buttongrp[3]=btnBack;
		
		btnSearch = new JButton("SEARCH");
		btnSearch.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSearch);
		btnSearch.setActionCommand("SEARCH");
		buttongrp[4]=btnSearch;
		
		btnForward = new JButton(">>");
		btnForward.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnForward);
		btnForward.setActionCommand(">>");
		buttongrp[5]=btnForward;
				
	}

	public JButton getBtnSave() {
		return btnSave;
	}

	public void setBtnSave(JButton btnSave) {
		this.btnSave = btnSave;
	}

	public JButton getBtnUpdate() {
		return btnUpdate;
	}

	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}

	public JButton getBtnBack() {
		return btnBack;
	}

	public void setBtnBack(JButton btnBack) {
		this.btnBack = btnBack;
	}

	public JButton getBtnSearch() {
		return btnSearch;
	}

	public void setBtnSearch(JButton btnSearch) {
		this.btnSearch = btnSearch;
	}

	public JButton getBtnForward() {
		return btnForward;
	}

	public void setBtnForward(JButton btnForward) {
		this.btnForward = btnForward;
	}

	public JButton getBtnClear() {
		return btnClear;
	}

	public void setBtnClear(JButton btnClear) {
		this.btnClear = btnClear;
	}

	public JTextField getTprojName() {
		return tfprojectName;
	}

	public void setTprojName(JTextField tprojName) {
		this.tfprojectName = tprojName;
	}

	public JTextField getTprojId() {
		return tfprojectId;
	}

	public void setTprojId(JTextField tprojId) {
		this.tfprojectId = tprojId;
	}

	

	public JLabel getLblprojectName() {
		return lblprojectName;
	}

	public void setLblprojectName(JLabel lblprojectName) {
		this.lblprojectName = lblprojectName;
	}

	public JTextField getTfprojectName() {
		return tfprojectName;
	}

	public void setTfprojectName(JTextField tfprojectName) {
		this.tfprojectName = tfprojectName;
	}

	public JTextField getTfprojectId() {
		return tfprojectId;
	}

	public void setTfprojectId(JTextField tfprojectId) {
		this.tfprojectId = tfprojectId;
	}

	public JLabel getLblActive() {
		return lblActive;
	}

	public void setLblActive(JLabel lblActive) {
		this.lblActive = lblActive;
	}
	
	

	public JButton getBtnMarkInactive() {
		return btnMarkInactive;
	}

	public void setBtnMarkInactive(JButton btnMarkInactive) {
		this.btnMarkInactive = btnMarkInactive;
	}

	public void actionListener(ActionListener al)
	{
		for(int i=0;i<buttongrp.length;i++)
		{
			buttongrp[i].addActionListener(al);
		}
	}
}
